<?php

include_once("core/controller.php");
include_once("core/versionHandler.php");

/**
 * @copyright inovia
 * @package oolime_manager  
 *
 */  
class homeMaintenance extends Controller{
  
  public function isLegitimate(){
    return true;
  }
  
  public function actions(){
		global $configMaintenance;
		global $configDispatcher;
		include('rights.php');
		$rights = $acts;
		
    /* maintenance node*/
    $ParentNode = $this->response->doc->createElement('maintenance');
    $SonNode  	= $this->response->doc->createElement('state');
    $valueSon 	= $this->response->doc->createTextNode($configMaintenance);
    $SonNode->appendChild($valueSon);
    $ParentNode->appendChild($SonNode);
    $this->response->add($ParentNode);
    
    /** 
     * Retrieves all the actions 
     */         
    $actionsNode = $this->response->doc->createElement('actions');
    foreach($configDispatcher as $action => $array){
      $actionNode  	= $this->response->doc->createElement('action');
      
      $node  	= $this->response->doc->createElement('name');
      $node->appendChild($this->response->doc->createTextNode($action));
      $actionNode->appendChild($node);      
      
      $node  	= $this->response->doc->createElement('output');
      $node->appendChild($this->response->doc->createTextNode($array[2]));
      $actionNode->appendChild($node);
      
      $groupsValue = "";
      foreach($rights[$action] as $val){
        $groupsValue .= $val.", ";
      }
      
      $node  	= $this->response->doc->createElement('groups');
      $node->appendChild($this->response->doc->createTextNode(substr($groupsValue, 0, -2)));
      $actionNode->appendChild($node);
      
      $node  	= $this->response->doc->createElement('maint');
      $node->appendChild($this->response->doc->createTextNode($array[3]));
      $actionNode->appendChild($node);
      
      $actionsNode->appendChild($actionNode);
    }
    $this->response->add($actionsNode);
    
		
    $versionH = new VersionHandler("");
    $this->response->add($versionH->getMyVersion());
    $dateNode = $this->response->doc->createElement("date");
    $dateNode->appendChild($this->response->doc->createTextNode(date("d/m/Y G:i")));
    $this->response->add($dateNode);         
    $this->response->setXSLT("views/manager/maintenance.xsl");
  }
  
  public function defaultActions(){
    $this->response->setXSLT("views/login.xsl");
  }
  
}

?>
